<?PHP
@session_start();
if($_SESSION['mxadmin']['username']=="" || empty($_SESSION['mxadmin']['username']) || $_SESSION['mxadmin']['purview']=="" || empty($_SESSION['mxadmin']['purview'])){
   echo "<script>window.parent.location='/mxsoft/Login.php';</script>";
   exit();
  }
 //读取管理员权限

$quanxian=$db->excu("SELECT Purview,ArticleIdPurview,OtherPurview,VideoIdPurview,PictureIdPurview FROM mx_members WHERE uid='".trim($_SESSION['mxadmin']['userid'])."' and password='".trim($_SESSION['mxadmin']['password'])."' and Purview='".trim($_SESSION['mxadmin']['purview'])."'");
if(mysql_num_rows($quanxian)!=1){
    echo "<script>window.parent.location='/mxsoft/Login.php';</script>";
    exit();
}

global $OtherPurview,$purview;
$quanxian=mysql_fetch_row($quanxian);
$Purview=$quanxian[0];
$ArticleIdPurview=$quanxian[1];
$OtherPurview="##@@@##".$quanxian[2];
$VideoIdPurview=$quanxian[3];
$PictureIdPurview=$quanxian[4];
$PurviewPassed=true;

global $fiddbadmin,$fiddbadmin2,$videofiddbadmin2;
if ($Purview==1){
    $fiddbadmin=Selectadminfid("mx_vpp_articleclass","0",$ArticleIdPurview,"true");
	$fiddbadmin=ltrim($fiddbadmin,",");
	$fiddbadmin2="|||".str_replace(",","|||",$fiddbadmin)."|||";
	$articlefidsql="";	
}
else
{
    $fiddbadmin=Selectadminfid("mx_vpp_articleclass","0",$ArticleIdPurview,"false");
	$fiddbadmin=ltrim($fiddbadmin,",");
	$fiddbadmin2="|||".str_replace(",","|||",$fiddbadmin)."|||";
	$articlefidsql=" and fid in ($fiddbadmin) ";
}


//判断管理员权限
function CheckPurview($AllPurviews,$strPurview){
	if (empty($AllPurviews) || empty($strPurview) || $AllPurviews=="" or $strPurview==""){
		return false;
	}
	$AllPurviews_ar=explode(",",$AllPurviews);
	for ($Purvi=0;$Purvi<count($AllPurviews_ar);$Purvi++)
	{
	  if ($AllPurviews_ar[$Purvi]==$strPurview){
		$checkpur=true;
		break;
	  }
	  else
	  {
		$checkpur=false;
	  }
	}
	return $checkpur;
}


if ($PurviewLevel>0){
  if ($Purview>$PurviewLevel)
	{$PurviewPassed=false;}
  else{
    if ($Purview==2){
      if ($CheckChannelID==0)
        {$PurviewPassed=CheckPurview(str_replace("##@@@##","",$OtherPurview),$PurviewLevel_Others);}
      elseif($CheckChannelID==1){
		if($ArticlePurview==""  && ArticleIdPurview==""){$PurviewPassed=false;}
	  }
      elseif($CheckChannelID==3){
		if($ArticlePurviewcj=="" ){$PurviewPassed=false;}
	  }
   }
}}

if ((!$PurviewPassed)){
    $fun->popmassage("对不起，你没有此项操作的权限。","","popback");
	exit();
}
?>
